Merged
Conversation
Since `_union` is only used in `Conjunction.__call__`, it makes sence to define it in `base.py` (where `Conjunction` is defined). Further, since `base.py` contains several classes, it makes sence to make `_union` a static method of specifically the `Conjunction` class. Lastly, since `Conjunction.__call__` is almost a trivial call to `_union`, it makes sense to have no `_union` method but to directly compute this union in the `__call__` method of `Conjunction`. This is kind of the opposite of a factorization, but it should enhance code readability since it limits the back-and-forth required to understand a piece of code.
- Since `dict_union` is only used in `stacks.py`, I think it's better to define it there. It makes less back-and-forth when reading the code, and it reduces the number of things that `_utils.py` has to contain. - Also remove _ValueType from _utils.py since it is now unused
- It now only contains the _materialize function, which can hardly be moved to another file since grad, jac and stack depend on it.
- materialize is in a protected file _materialize.py, which means that only members of the local transform package can import from it. There is thus no point in make the materialize function itself protected. In fact, this would mean that the materialize function should not be used outside _materialize.py, while in fact, it has to be used in grad.py, jac.py, and stack.py.
- Same reason as materialize
This was referenced Apr 3, 2025
Closed
Codecov ReportAll modified and coverable lines are covered by tests ✅
🚀 New features to boost your workflow:
|
PierreQuinton
approved these changes
Apr 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The goal here is to get rid of an overused utils.py file, to stop having factorized code when it's used only in a single Transform and to fix protection issues. This should not have any impact on anything for the user, as it's (supposedly) just moving code around and renaming internal things.